home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / flying-6.11 / mover.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-30  |  2.4 KB  |  138 lines

  1. #ifndef _global_h
  2. #    include "global.h"
  3. #endif
  4.  
  5. #ifndef _mover_h
  6. #    include "mover.h"
  7. #endif
  8. #ifndef _vec2_h
  9. #    include "vec2.h"
  10. #endif
  11. #ifndef _graph_h
  12. #    include "graph.h"
  13. #endif
  14.  
  15. /*----------------------------------------------------------------------------*/
  16.  
  17. #ifndef __TURBOC__
  18. #    include "xmover.C"
  19. #else
  20. #    include "dosmover.C"
  21. #endif
  22.  
  23. /*----------------------------------------------------------------------------*/
  24.  
  25. BallStateTop::BallStateTop()                                        {}
  26. BallStateTop::~BallStateTop()                                        {}
  27. void BallStateTop::Redraw()                                        {}
  28. void BallStateTop::Show()                                            {}
  29. void BallStateTop::MoveTo( const Vec2& /*new_pos*/ )    {}
  30. void BallStateTop::Hide()                                            {}
  31.  
  32. /*----------------------------------------------------------------------------*/
  33.  
  34.  
  35. BallState::BallState( BallMover *m_in, ColorId col_in, const Vec2 &pos ) {
  36.     vis = 0;
  37.     m   = m_in;
  38.     if (!m) {
  39.         printf( "BallState: Error: BallMover not initialized\n" );
  40.     }
  41.     col = col_in;
  42.     for (col_x=0;col_x<nball_ids;col_x++) {
  43.         if (col==ball_ids[col_x])                    break;
  44.     }
  45.     x = (int)(pos.X()*w2n);
  46.     y = (int)(pos.Y()*w2n);
  47.     DBG3( BState, "BallState(%d,<%d,%d>)", col_in, x,y );
  48. }
  49.  
  50. BallState::~BallState() {
  51. }
  52.  
  53.  
  54. void BallState::Redraw() {
  55.     vis=1;
  56.     m->DrawBallAt(x,y,col_x);
  57. }
  58.  
  59. void BallState::Show() {
  60.     if (!vis) {
  61.         vis=1;
  62.         m->DrawBallAt(x,y,col_x);
  63.     }
  64. }
  65.  
  66.  
  67. void BallState::MoveTo( const Vec2 &pos ) {
  68. int    newx;
  69. int    newy;
  70.  
  71.     newx = (int)(pos.X()*w2n);
  72.     newy = (int)(pos.Y()*w2n);
  73.     if (newx!=x||newy!=y) {
  74.         m->MoveBallOnScreen(x,y,newx,newy,col_x);
  75.         x = newx;
  76.         y = newy;
  77.     }
  78. }
  79.  
  80.  
  81. void BallState::Hide() {
  82.     if (vis) {
  83.         vis=0;
  84.         m->DrawBallAt(x,y,col_x);
  85.     }
  86. }
  87.  
  88. /*----------------------------------------------------------------------------*/
  89.  
  90.  
  91. HalfBallState::HalfBallState( BallMover *m_in, ColorId col_in, const Vec2 &pos ) :
  92.     BallState( m_in, col_in, pos )
  93. {
  94.     mh = (HalfBallMover *)m_in;
  95. #ifndef __TURBOC__
  96.     st=mh->AngVec2St(rand()%mh->vecs_l,rand()%mh->vecs_b);
  97. #endif
  98. }
  99.  
  100. HalfBallState::~HalfBallState() {
  101. }
  102.  
  103. void HalfBallState::Redraw() {
  104.     vis=1;
  105.     mh->RollBallAt(x,y,st,col_x);
  106. }
  107.  
  108. void HalfBallState::Show() {
  109.     if (!vis) {
  110.         vis=1;
  111.         mh->RollBallAt(x,y,st,col_x);
  112.     }
  113. }
  114.  
  115.  
  116. void HalfBallState::MoveTo( const Vec2 &pos ) {
  117. int            newx;
  118. int            newy;
  119. RingState    nst;
  120.  
  121.     newx = (int)(pos.X()*w2n);
  122.     newy = (int)(pos.Y()*w2n);
  123.     if (newx!=x||newy!=y) {
  124.         mh->RollBallOnScreen(x,y,st,newx,newy,&nst,col_x);
  125.         x    = newx;
  126.         y    = newy;
  127.         st = nst;
  128.     }
  129. }
  130.  
  131.  
  132. void HalfBallState::Hide() {
  133.     if (vis) {
  134.         vis=0;
  135.         mh->RollBallAt(x,y,st,col_x);
  136.     }
  137. }
  138.